import axios, {AxiosRequestConfig, AxiosResponse} from "axios";

interface RequestConf extends AxiosRequestConfig {

}

class Request {
    constructor() {
    }

    get<T = any>(props: AxiosRequestConfig) {
        return new Promise<AxiosResponse<T>>((resolve, reject) =>{
            axios(props).then((result: AxiosResponse<T>) => {
                resolve(result);
            }).catch((result: AxiosResponse<T>) =>{
                reject(result);
            });
        })
    }

    post<T = any>(props: AxiosRequestConfig) {
        return new Promise<AxiosResponse<T>>((resolve, reject) =>{
            axios(props).then((result: AxiosResponse<T>) => {
                resolve(result);
            }).catch((result: AxiosResponse<T>) =>{
                reject(result);
            });
        })
    }

}

export default new Request();